<template>
  <a-modal
    :title="title"
    :width="1200"
    :visible="visible"
    :maskClosable="false"
    :confirmLoading="confirmLoading"
    @ok="handleOk"
    @cancel="handleCancel">
    <a-spin :spinning="confirmLoading">
      <!-- 主表单区域 -->
      <a-form :form="form">
        <a-row>
          <a-col :span="12" :gutter="8">
            <a-form-item
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              label="memberId">
              <a-input placeholder="请输入memberId" v-decorator="['memberId', validatorRules.memberId ]"/>
            </a-form-item>
          </a-col>
          <a-col :span="12" :gutter="8">
            <a-form-item
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              label="couponId">
              <a-input placeholder="请输入couponId" v-decorator="['couponId', {}]"/>
            </a-form-item>
          </a-col>
        </a-row>
        <a-row>
          <a-col :span="12" :gutter="8">
            <a-form-item
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              label="订单编号">
              <a-input placeholder="请输入订单编号" v-decorator="['orderSn', {}]"/>
            </a-form-item>
          </a-col>
          <a-col :span="12" :gutter="8">
            <a-form-item
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              label="用户帐号">
              <a-input placeholder="请输入用户帐号" v-decorator="['memberUsername', {}]"/>
            </a-form-item>
          </a-col>
        </a-row>
        <a-row>
          <a-col :span="12" :gutter="8">
            <a-form-item
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              label="订单总金额">
              <a-input-number placeholder="请输入订单总金额" style="width:100%" v-decorator="[ 'totalAmount', {}]"/>
            </a-form-item>
          </a-col>
          <a-col :span="12" :gutter="8">
            <a-form-item
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              label="应付金额（实际支付金额）">
              <a-input-number placeholder="请输入应付金额（实际支付金额）" style="width:100%" v-decorator="[ 'payAmount', {}]"/>
            </a-form-item>
          </a-col>
        </a-row>
        <a-row>
          <a-col :span="12" :gutter="8">
            <a-form-item
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              label="有效金额（实付金额-退款金额）">
              <a-input-number placeholder="请输入有效金额（实付金额-退款金额）" style="width:100%" v-decorator="[ 'effectiveAmount', {}]"/>
            </a-form-item>
          </a-col>
          <a-col :span="12" :gutter="8">
            <a-form-item
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              label="运费金额">
              <a-input-number placeholder="请输入运费金额" style="width:100%" v-decorator="[ 'freightAmount', {}]"/>
            </a-form-item>
          </a-col>
        </a-row>
        <a-row>
          <a-col :span="12" :gutter="8">
            <a-form-item
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              label="促销优化金额（促销价、满减、阶梯价）">
              <a-input-number placeholder="请输入促销优化金额（促销价、满减、阶梯价）" style="width:100%" v-decorator="[ 'promotionAmount', {}]"/>
            </a-form-item>
          </a-col>
          <a-col :span="12" :gutter="8">
            <a-form-item
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              label="积分抵扣金额">
              <a-input-number placeholder="请输入积分抵扣金额" style="width:100%" v-decorator="[ 'integrationAmount', {}]"/>
            </a-form-item>
          </a-col>
        </a-row>
        <a-row>
          <a-col :span="12" :gutter="8">
            <a-form-item
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              label="优惠券抵扣金额">
              <a-input-number placeholder="请输入优惠券抵扣金额" style="width:100%" v-decorator="[ 'couponAmount', {}]"/>
            </a-form-item>
          </a-col>
          <a-col :span="12" :gutter="8">
            <a-form-item
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              label="管理员后台调整订单使用的折扣金额">
              <a-input-number placeholder="请输入管理员后台调整订单使用的折扣金额" style="width:100%" v-decorator="[ 'discountAmount', {}]"/>
            </a-form-item>
          </a-col>
        </a-row>
        <a-row>
          <a-col :span="12" :gutter="8">
            <a-form-item
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              label="红包抵扣金额">
              <a-input-number placeholder="请输入红包抵扣金额" style="width:100%" v-decorator="[ 'redbagAmount', {}]"/>
            </a-form-item>
          </a-col>
          <a-col :span="12" :gutter="8">
            <a-form-item
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              label="支付方式：ali->支付宝；wx->微信；union->银联">
              <a-input placeholder="请输入支付方式：ali->支付宝；wx->微信；union->银联" v-decorator="['payType', {}]"/>
            </a-form-item>
          </a-col>
        </a-row>
        <a-row>
          <a-col :span="12" :gutter="8">
            <a-form-item
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              label="订单来源：pc->PC订单；app->app订单">
              <a-input placeholder="请输入订单来源：pc->PC订单；app->app订单" v-decorator="['sourceType', {}]"/>
            </a-form-item>
          </a-col>
          <a-col :span="12" :gutter="8">
            <a-form-item
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              label="下单的系统；smart智能终端,baisheng百胜os,shop门店, online新商城,admin后台下单，third三方平台">
              <a-input placeholder="请输入下单的系统；smart智能终端,baisheng百胜os,shop门店, online新商城,admin后台下单，third三方平台" v-decorator="['sourceSystem', {}]"/>
            </a-form-item>
          </a-col>
        </a-row>
        <a-row>
          <a-col :span="12" :gutter="8">
            <a-form-item
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              label="下单时终端类型：pc/wap/ios/android/miniprogram">
              <a-input placeholder="请输入下单时终端类型：pc/wap/ios/android/miniprogram" v-decorator="['sourceScreen', {}]"/>
            </a-form-item>
          </a-col>
          <a-col :span="12" :gutter="8">
            <a-form-item
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              label="下单时的操作系统: window/mac/android">
              <a-input placeholder="请输入下单时的操作系统: window/mac/android" v-decorator="['sourceOs', {}]"/>
            </a-form-item>
          </a-col>
        </a-row>
        <a-row>
          <a-col :span="12" :gutter="8">
            <a-form-item
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              label="下单的用户ip">
              <a-input placeholder="请输入下单的用户ip" v-decorator="['sourceIp', {}]"/>
            </a-form-item>
          </a-col>
          <a-col :span="12" :gutter="8">
            <a-form-item
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              label="订单状态：0->待付款；1->待发货；2->已发货；3->已收货；4->已取消；">
              <a-input-number placeholder="请输入订单状态：0->待付款；1->待发货；2->已发货；3->已收货；4->已取消；" style="width:100%" v-decorator="[ 'status', {}]"/>
            </a-form-item>
          </a-col>
        </a-row>
        <a-row>
          <a-col :span="12" :gutter="8">
            <a-form-item
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              label="货品状态(0：不发货；1：锁定（默认）；2：等待下发；3：已下发；4：已发货；5：已签收；6：直接退货中；7：直接退货入库)">
              <a-input-number placeholder="请输入货品状态(0：不发货；1：锁定（默认）；2：等待下发；3：已下发；4：已发货；5：已签收；6：直接退货中；7：直接退货入库)" style="width:100%" v-decorator="[ 'productStatus', {}]"/>
            </a-form-item>
          </a-col>
          <a-col :span="12" :gutter="8">
            <a-form-item
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              label="支付状态；0：不支付；1：支付锁定；2：等待下发（默认）；3：已下发；4：已支付；(未支付：1、2、3，等待支付：2、3)">
              <a-input-number placeholder="请输入支付状态；0：不支付；1：支付锁定；2：等待下发（默认）；3：已下发；4：已支付；(未支付：1、2、3，等待支付：2、3)" style="width:100%" v-decorator="[ 'payStatus', {}]"/>
            </a-form-item>
          </a-col>
        </a-row>
        <a-row>
          <a-col :span="12" :gutter="8">
            <a-form-item
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              label="0:默认，1：部分退货，2：全部退货">
              <a-input-number placeholder="请输入0:默认，1：部分退货，2：全部退货" style="width:100%" v-decorator="[ 'returnStatus', {}]"/>
            </a-form-item>
          </a-col>
          <a-col :span="12" :gutter="8">
            <a-form-item
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              label="订单类型：0->正常订单；1->秒杀订单">
              <a-input-number placeholder="请输入订单类型：0->正常订单；1->秒杀订单" style="width:100%" v-decorator="[ 'orderType', {}]"/>
            </a-form-item>
          </a-col>
        </a-row>
        <a-row>
          <a-col :span="12" :gutter="8">
            <a-form-item
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              label="物流公司(配送方式)">
              <a-input placeholder="请输入物流公司(配送方式)" v-decorator="['deliveryCompany', {}]"/>
            </a-form-item>
          </a-col>
          <a-col :span="12" :gutter="8">
            <a-form-item
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              label="物流单号">
              <a-input placeholder="请输入物流单号" v-decorator="['deliverySn', {}]"/>
            </a-form-item>
          </a-col>
        </a-row>
        <a-row>
          <a-col :span="12" :gutter="8">
            <a-form-item
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              label="自动确认时间（天）">
              <a-input-number placeholder="请输入自动确认时间（天）" style="width:100%" v-decorator="[ 'autoConfirmDay', {}]"/>
            </a-form-item>
          </a-col>
          <a-col :span="12" :gutter="8">
            <a-form-item
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              label="可以获得的积分">
              <a-input-number placeholder="请输入可以获得的积分" style="width:100%" v-decorator="[ 'integration', {}]"/>
            </a-form-item>
          </a-col>
        </a-row>
        <a-row>
          <a-col :span="12" :gutter="8">
            <a-form-item
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              label="可以活动的成长值">
              <a-input-number placeholder="请输入可以活动的成长值" style="width:100%" v-decorator="[ 'growth', {}]"/>
            </a-form-item>
          </a-col>
          <a-col :span="12" :gutter="8">
            <a-form-item
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              label="活动信息">
              <a-input placeholder="请输入活动信息" v-decorator="['promotionInfo', {}]"/>
            </a-form-item>
          </a-col>
        </a-row>
        <a-row>
          <a-col :span="12" :gutter="8">
            <a-form-item
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              label="发票类型：0->不开发票；1->电子发票；2->纸质发票">
              <a-input-number placeholder="请输入发票类型：0->不开发票；1->电子发票；2->纸质发票" style="width:100%" v-decorator="[ 'billType', {}]"/>
            </a-form-item>
          </a-col>
          <a-col :span="12" :gutter="8">
            <a-form-item
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              label="发票抬头">
              <a-input placeholder="请输入发票抬头" v-decorator="['billHeader', {}]"/>
            </a-form-item>
          </a-col>
        </a-row>
        <a-row>
          <a-col :span="12" :gutter="8">
            <a-form-item
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              label="发票内容">
              <a-input placeholder="请输入发票内容" v-decorator="['billContent', {}]"/>
            </a-form-item>
          </a-col>
          <a-col :span="12" :gutter="8">
            <a-form-item
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              label="收票人电话">
              <a-input placeholder="请输入收票人电话" v-decorator="['billReceiverPhone', {}]"/>
            </a-form-item>
          </a-col>
        </a-row>
        <a-row>
          <a-col :span="12" :gutter="8">
            <a-form-item
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              label="收票人邮箱">
              <a-input placeholder="请输入收票人邮箱" v-decorator="['billReceiverEmail', {}]"/>
            </a-form-item>
          </a-col>
          <a-col :span="12" :gutter="8">
            <a-form-item
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              label="收货人姓名">
              <a-input placeholder="请输入收货人姓名" v-decorator="['receiverName', validatorRules.receiverName ]"/>
            </a-form-item>
          </a-col>
        </a-row>
        <a-row>
          <a-col :span="12" :gutter="8">
            <a-form-item
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              label="收货人电话">
              <a-input placeholder="请输入收货人电话" v-decorator="['receiverPhone', validatorRules.receiverPhone ]"/>
            </a-form-item>
          </a-col>
          <a-col :span="12" :gutter="8">
            <a-form-item
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              label="收货人邮编">
              <a-input placeholder="请输入收货人邮编" v-decorator="['receiverPostCode', {}]"/>
            </a-form-item>
          </a-col>
        </a-row>
        <a-row>
          <a-col :span="12" :gutter="8">
            <a-form-item
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              label="省份/直辖市">
              <a-input placeholder="请输入省份/直辖市" v-decorator="['receiverProvince', {}]"/>
            </a-form-item>
          </a-col>
          <a-col :span="12" :gutter="8">
            <a-form-item
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              label="城市">
              <a-input placeholder="请输入城市" v-decorator="['receiverCity', {}]"/>
            </a-form-item>
          </a-col>
        </a-row>
        <a-row>
          <a-col :span="12" :gutter="8">
            <a-form-item
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              label="区">
              <a-input placeholder="请输入区" v-decorator="['receiverRegion', {}]"/>
            </a-form-item>
          </a-col>
          <a-col :span="12" :gutter="8">
            <a-form-item
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              label="详细地址">
              <a-input placeholder="请输入详细地址" v-decorator="['receiverDetailAddress', {}]"/>
            </a-form-item>
          </a-col>
        </a-row>
        <a-row>
          <a-col :span="12" :gutter="8">
            <a-form-item
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              label="订单备注">
              <a-input placeholder="请输入订单备注" v-decorator="['note', {}]"/>
            </a-form-item>
          </a-col>
          <a-col :span="12" :gutter="8">
            <a-form-item
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              label="确认收货状态：0->未确认；1->已确认">
              <a-input-number placeholder="请输入确认收货状态：0->未确认；1->已确认" style="width:100%" v-decorator="[ 'confirmStatus', {}]"/>
            </a-form-item>
          </a-col>
        </a-row>
        <a-row>
          <a-col :span="12" :gutter="8">
            <a-form-item
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              label="删除状态：0->未删除；1->已删除">
              <a-input-number placeholder="请输入删除状态：0->未删除；1->已删除" style="width:100%" v-decorator="[ 'deleteStatus', validatorRules.deleteStatus ]"/>
            </a-form-item>
          </a-col>
          <a-col :span="12" :gutter="8">
            <a-form-item
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              label="下单时使用的积分">
              <a-input-number placeholder="请输入下单时使用的积分" style="width:100%" v-decorator="[ 'useIntegration', {}]"/>
            </a-form-item>
          </a-col>
        </a-row>
        <a-row>
          <a-col :span="12" :gutter="8">
            <a-form-item
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              label="支付时间">
              <a-date-picker
                placeholder="请输入支付时间"
                style="width:100%"
                :showTime="true"
                format="YYYY-MM-DD HH:mm:ss"
                v-decorator="[ 'paymentTime', {}]"/>
            </a-form-item>
          </a-col>
          <a-col :span="12" :gutter="8">
            <a-form-item
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              label="发货时间">
              <a-date-picker
                placeholder="请输入发货时间"
                style="width:100%"
                :showTime="true"
                format="YYYY-MM-DD HH:mm:ss"
                v-decorator="[ 'deliveryTime', {}]"/>
            </a-form-item>
          </a-col>
        </a-row>
        <a-row>
          <a-col :span="12" :gutter="8">
            <a-form-item
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              label="确认收货时间">
              <a-date-picker
                placeholder="请输入确认收货时间"
                style="width:100%"
                :showTime="true"
                format="YYYY-MM-DD HH:mm:ss"
                v-decorator="[ 'receiveTime', {}]"/>
            </a-form-item>
          </a-col>
          <a-col :span="12" :gutter="8">
            <a-form-item
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              label="评价时间">
              <a-date-picker
                placeholder="请输入评价时间"
                style="width:100%"
                :showTime="true"
                format="YYYY-MM-DD HH:mm:ss"
                v-decorator="[ 'commentTime', {}]"/>
            </a-form-item>
          </a-col>
        </a-row>
        <a-row>
          <a-col :span="12" :gutter="8">
            <a-form-item
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              label="修改时间">
              <a-date-picker
                placeholder="请输入修改时间"
                style="width:100%"
                :showTime="true"
                format="YYYY-MM-DD HH:mm:ss"
                v-decorator="[ 'modifyTime', {}]"/>
            </a-form-item>
          </a-col>
          <a-col :span="12" :gutter="8">
            <a-form-item
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              label="外部来源类型：ad,cps,ref">
              <a-input placeholder="请输入外部来源类型：ad,cps,ref" v-decorator="['netSourceType', {}]"/>
            </a-form-item>
          </a-col>
        </a-row>
        <a-row>
          <a-col :span="12" :gutter="8">
            <a-form-item
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              label="一级来源(keyname)">
              <a-input placeholder="请输入一级来源(keyname)" v-decorator="['netSourceArg1', {}]"/>
            </a-form-item>
          </a-col>
          <a-col :span="12" :gutter="8">
            <a-form-item
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              label="二级来源(keysource)">
              <a-input placeholder="请输入二级来源(keysource)" v-decorator="['netSourceArg2', {}]"/>
            </a-form-item>
          </a-col>
        </a-row>
        <a-row>
          <a-col :span="12" :gutter="8">
            <a-form-item
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              label="三级来源">
              <a-input placeholder="请输入三级来源" v-decorator="['netSourceArg3', {}]"/>
            </a-form-item>
          </a-col>
          <a-col :span="12" :gutter="8">
            <a-form-item
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              label="四级来源">
              <a-input placeholder="请输入四级来源" v-decorator="['netSourceArg4', {}]"/>
            </a-form-item>
          </a-col>
        </a-row>
        <a-row>
          <a-col :span="12" :gutter="8">
            <a-form-item
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              label="来源明细">
              <a-input placeholder="请输入来源明细" v-decorator="['netSourceArgdetail', {}]"/>
            </a-form-item>
          </a-col>
        </a-row>
      </a-form>

      <!-- 子表单区域 -->
      <a-tabs v-model="activeKey" @change="handleChangeTabs">
        <a-tab-pane tab="订单明细" :key="refKeys[0]" :forceRender="true">
          <j-editable-table
            :ref="refKeys[0]"
            :loading="omsOrderItemTable.loading"
            :columns="omsOrderItemTable.columns"
            :dataSource="omsOrderItemTable.dataSource"
            :maxHeight="300"
            :rowNumber="true"
            :rowSelection="true"
            :actionButton="true"/>
        </a-tab-pane>
        <a-tab-pane tab="订单发票" :key="refKeys[1]" :forceRender="true">
          <j-editable-table
            :ref="refKeys[1]"
            :loading="omsOrderInvoiceTable.loading"
            :columns="omsOrderInvoiceTable.columns"
            :dataSource="omsOrderInvoiceTable.dataSource"
            :maxHeight="300"
            :rowNumber="true"
            :rowSelection="true"
            :actionButton="true"/>
        </a-tab-pane>
      </a-tabs>

    </a-spin>
  </a-modal>
</template>

<script>

  import moment from 'moment'
  import pick from 'lodash.pick'
  import { FormTypes } from '@/utils/JEditableTableUtil'
  import { JEditableTableMixin } from '@/mixins/JEditableTableMixin'

  export default {
    name: 'OmsOrderModal',
    mixins: [JEditableTableMixin],
    data() {
      return {
        // 新增时子表默认添加几行空数据
        addDefaultRowNum: 1,
        validatorRules: {
          memberId: { rules: [{ required: true, message: '请输入memberId!' }] },
          receiverName: { rules: [{ required: true, message: '请输入收货人姓名!' }] },
          receiverPhone: { rules: [{ required: true, message: '请输入收货人电话!' }] },
          deleteStatus: { rules: [{ required: true, message: '请输入删除状态：0->未删除；1->已删除!' }] },
        },
        refKeys: ['omsOrderItem', 'omsOrderInvoice', ],
        activeKey: 'omsOrderItem',
        // 订单明细
        omsOrderItemTable: {
          loading: false,
          dataSource: [],
          columns: [
            {
              title: '订单id',
              key: 'orderId',
              type: FormTypes.input,
              defaultValue: '',
              placeholder: '请输入${title}',
            },
            {
              title: '订单编号',
              key: 'orderSn',
              type: FormTypes.input,
              defaultValue: '',
              placeholder: '请输入${title}',
            },
            {
              title: '商品id',
              key: 'productId',
              type: FormTypes.input,
              defaultValue: '',
              placeholder: '请输入${title}',
            },
            {
              title: '商品图片',
              key: 'productPic',
              type: FormTypes.input,
              defaultValue: '',
              placeholder: '请输入${title}',
            },
            {
              title: '商品名称',
              key: 'productName',
              type: FormTypes.input,
              defaultValue: '',
              placeholder: '请输入${title}',
            },
            {
              title: '商品品牌',
              key: 'productBrand',
              type: FormTypes.input,
              defaultValue: '',
              placeholder: '请输入${title}',
            },
            {
              title: '商品货号',
              key: 'productSn',
              type: FormTypes.input,
              defaultValue: '',
              placeholder: '请输入${title}',
            },
            {
              title: '销售价格',
              key: 'productPrice',
              type: FormTypes.inputNumber,
              defaultValue: '',
              placeholder: '请输入${title}',
            },
            {
              title: '购买数量',
              key: 'productQuantity',
              type: FormTypes.inputNumber,
              defaultValue: '',
              placeholder: '请输入${title}',
            },
            {
              title: '商品sku编号',
              key: 'productSkuId',
              type: FormTypes.input,
              defaultValue: '',
              placeholder: '请输入${title}',
            },
            {
              title: '商品sku条码',
              key: 'productSkuCode',
              type: FormTypes.input,
              defaultValue: '',
              placeholder: '请输入${title}',
            },
            {
              title: '商品分类id',
              key: 'productCategoryId',
              type: FormTypes.input,
              defaultValue: '',
              placeholder: '请输入${title}',
            },
            {
              title: '商品的销售属性',
              key: 'sp1',
              type: FormTypes.input,
              defaultValue: '',
              placeholder: '请输入${title}',
            },
            {
              title: 'sp2',
              key: 'sp2',
              type: FormTypes.input,
              defaultValue: '',
              placeholder: '请输入${title}',
            },
            {
              title: 'sp3',
              key: 'sp3',
              type: FormTypes.input,
              defaultValue: '',
              placeholder: '请输入${title}',
            },
            {
              title: '商品促销名称',
              key: 'promotionName',
              type: FormTypes.input,
              defaultValue: '',
              placeholder: '请输入${title}',
            },
            {
              title: '商品促销分解金额',
              key: 'promotionAmount',
              type: FormTypes.inputNumber,
              defaultValue: '',
              placeholder: '请输入${title}',
            },
            {
              title: '优惠券优惠分解金额',
              key: 'couponAmount',
              type: FormTypes.inputNumber,
              defaultValue: '',
              placeholder: '请输入${title}',
            },
            {
              title: '积分优惠分解金额',
              key: 'integrationAmount',
              type: FormTypes.inputNumber,
              defaultValue: '',
              placeholder: '请输入${title}',
            },
            {
              title: '该商品经过优惠后的分解金额',
              key: 'realAmount',
              type: FormTypes.inputNumber,
              defaultValue: '',
              placeholder: '请输入${title}',
            },
            {
              title: '商品赠送积分',
              key: 'giftIntegration',
              type: FormTypes.inputNumber,
              defaultValue: '',
              placeholder: '请输入${title}',
            },
            {
              title: '商品赠送成长值',
              key: 'giftGrowth',
              type: FormTypes.inputNumber,
              defaultValue: '',
              placeholder: '请输入${title}',
            },
            {
              title: '商品销售属性:[{"key":"颜色","value":"颜色"},{"key":"容量","value":"4G"}]',
              key: 'productAttr',
              type: FormTypes.input,
              defaultValue: '',
              placeholder: '请输入${title}',
            },
            {
              title: '外部来源类型：ad,cps,ref',
              key: 'netSourceType',
              type: FormTypes.input,
              defaultValue: '',
              placeholder: '请输入${title}',
            },
            {
              title: '一级来源(keyname)',
              key: 'netSourceArg1',
              type: FormTypes.input,
              defaultValue: '',
              placeholder: '请输入${title}',
            },
            {
              title: '二级来源(keysource)',
              key: 'netSourceArg2',
              type: FormTypes.input,
              defaultValue: '',
              placeholder: '请输入${title}',
            },
            {
              title: '三级来源',
              key: 'netSourceArg3',
              type: FormTypes.input,
              defaultValue: '',
              placeholder: '请输入${title}',
            },
            {
              title: '四级来源',
              key: 'netSourceArg4',
              type: FormTypes.input,
              defaultValue: '',
              placeholder: '请输入${title}',
            },
            {
              title: '来源明细',
              key: 'netSourceArgdetail',
              type: FormTypes.input,
              defaultValue: '',
              placeholder: '请输入${title}',
            },
            {
              title: '商品促销金额',
              key: 'totalPromotionAmount',
              type: FormTypes.inputNumber,
              defaultValue: '',
              placeholder: '请输入${title}',
            },
            {
              title: '优惠券优惠金额',
              key: 'totalCouponAmount',
              type: FormTypes.inputNumber,
              defaultValue: '',
              placeholder: '请输入${title}',
            },
            {
              title: '积分优惠金额',
              key: 'totalIntegrationAmount',
              type: FormTypes.inputNumber,
              defaultValue: '',
              placeholder: '请输入${title}',
            },
            {
              title: '红包优惠金额',
              key: 'totalRedbagAmount',
              type: FormTypes.inputNumber,
              defaultValue: '',
              placeholder: '请输入${title}',
            },
            {
              title: '小计金额(单价*数量-促销-优惠券-积分-红包)',
              key: 'totalRealAmount',
              type: FormTypes.inputNumber,
              defaultValue: '',
              placeholder: '请输入${title}',
            },
            {
              title: '申请退货数量',
              key: 'returnApplyQuantity',
              type: FormTypes.inputNumber,
              defaultValue: '',
              placeholder: '请输入${title}',
            },
            {
              title: '实际退货数量',
              key: 'returnRealQuantity',
              type: FormTypes.inputNumber,
              defaultValue: '',
              placeholder: '请输入${title}',
            },
            {
              title: '订单商品类型，0：普通商品，1：赠品',
              key: 'orderProductType',
              type: FormTypes.input,
              defaultValue: '',
              placeholder: '请输入${title}',
            },
          ]
        },
        // 订单发票
        omsOrderInvoiceTable: {
          loading: false,
          dataSource: [],
          columns: [
            {
              title: '订单id',
              key: 'orderId',
              type: FormTypes.input,
              defaultValue: '',
              placeholder: '请输入${title}',
            },
            {
              title: '发票类型：0：个人普票，1：企业普票，2：企业专票',
              key: 'invoiceType',
              type: FormTypes.input,
              defaultValue: '',
              placeholder: '请输入${title}',
            },
            {
              title: '发票抬头',
              key: 'invoiceTitle',
              type: FormTypes.input,
              defaultValue: '',
              placeholder: '请输入${title}',
            },
            {
              title: '发票内容',
              key: 'invoiceContent',
              type: FormTypes.input,
              defaultValue: '',
              placeholder: '请输入${title}',
            },
            {
              title: '发票金额',
              key: 'invoiceAmount',
              type: FormTypes.inputNumber,
              defaultValue: '',
              placeholder: '请输入${title}',
            },
            {
              title: '开票税金',
              key: 'invoiceTax',
              type: FormTypes.inputNumber,
              defaultValue: '',
              placeholder: '请输入${title}',
            },
            {
              title: '发票税号(纳税人识别号)',
              key: 'invoiceTaxNo',
              type: FormTypes.input,
              defaultValue: '',
              placeholder: '请输入${title}',
            },
            {
              title: '公司名称[增值税]',
              key: 'vatCompanyName',
              type: FormTypes.input,
              defaultValue: '',
              placeholder: '请输入${title}',
            },
            {
              title: '公司地址[增值税]',
              key: 'vatAddress',
              type: FormTypes.input,
              defaultValue: '',
              placeholder: '请输入${title}',
            },
            {
              title: '公司电话[增值税]',
              key: 'vatPhone',
              type: FormTypes.input,
              defaultValue: '',
              placeholder: '请输入${title}',
            },
            {
              title: '开户银行[增值税]',
              key: 'vatBankName',
              type: FormTypes.input,
              defaultValue: '',
              placeholder: '请输入${title}',
            },
            {
              title: '银行帐号[增值税]',
              key: 'vatBankAccount',
              type: FormTypes.input,
              defaultValue: '',
              placeholder: '请输入${title}',
            },
            {
              title: '发票状态：0->未开票，1->已开票',
              key: 'invoiceStatus',
              type: FormTypes.inputNumber,
              defaultValue: '',
              placeholder: '请输入${title}',
            },
            {
              title: '注销状态：0->未注销；1->已注销',
              key: 'deleteStatus',
              type: FormTypes.inputNumber,
              defaultValue: '',
              placeholder: '请输入${title}',
            },
            {
              title: '收票人姓名',
              key: 'receiverName',
              type: FormTypes.input,
              defaultValue: '',
              placeholder: '请输入${title}',
            },
            {
              title: '收票人手机',
              key: 'receiverPhone',
              type: FormTypes.input,
              defaultValue: '',
              placeholder: '请输入${title}',
            },
            {
              title: '收票人区域',
              key: 'receiverArea',
              type: FormTypes.input,
              defaultValue: '',
              placeholder: '请输入${title}',
            },
            {
              title: '收票人详细地址',
              key: 'receiverAddress',
              type: FormTypes.input,
              defaultValue: '',
              placeholder: '请输入${title}',
            },
            {
              title: '收票人邮箱',
              key: 'receiverEmail',
              type: FormTypes.input,
              defaultValue: '',
              placeholder: '请输入${title}',
            },
            {
              title: '快递公司ID',
              key: 'expressId',
              type: FormTypes.input,
              defaultValue: '',
              placeholder: '请输入${title}',
            },
            {
              title: '快递单号',
              key: 'expressNo',
              type: FormTypes.input,
              defaultValue: '',
              placeholder: '请输入${title}',
            },
            {
              title: '下载地址',
              key: 'invoiceUrl',
              type: FormTypes.input,
              defaultValue: '',
              placeholder: '请输入${title}',
            },
            {
              title: '发票号码',
              key: 'invoiceNo',
              type: FormTypes.input,
              defaultValue: '',
              placeholder: '请输入${title}',
            },
            {
              title: '发票代码',
              key: 'invoiceDm',
              type: FormTypes.input,
              defaultValue: '',
              placeholder: '请输入${title}',
            },
            {
              title: '红冲发票地址',
              key: 'redInvoiceUrl',
              type: FormTypes.input,
              defaultValue: '',
              placeholder: '请输入${title}',
            },
            {
              title: '红冲发票号码',
              key: 'redInvoiceNo',
              type: FormTypes.input,
              defaultValue: '',
              placeholder: '请输入${title}',
            },
            {
              title: '红冲发票代码',
              key: 'redInvoiceDm',
              type: FormTypes.input,
              defaultValue: '',
              placeholder: '请输入${title}',
            },
            {
              title: '红冲时间',
              key: 'redInvoiceTime',
              type: FormTypes.datetime,
              defaultValue: '',
              placeholder: '请输入${title}',
            },
            {
              title: '红冲发票金额',
              key: 'redInvoiceAmount',
              type: FormTypes.inputNumber,
              defaultValue: '',
              placeholder: '请输入${title}',
            },
            {
              title: '红冲发票税额',
              key: 'redInvoiceTax',
              type: FormTypes.inputNumber,
              defaultValue: '',
              placeholder: '请输入${title}',
            },
          ]
        },
        url: {
          add: "/oms/omsOrder/add",
          edit: "/oms/omsOrder/edit",
          omsOrderItem: {
            list: '/oms/omsOrder/queryOmsOrderItemByMainId'
          },
          omsOrderInvoice: {
            list: '/oms/omsOrder/queryOmsOrderInvoiceByMainId'
          },
        }
      }
    },
    methods: {
 
      /** 调用完edit()方法之后会自动调用此方法 */
      editAfter() {
        this.$nextTick(() => {
          this.form.setFieldsValue(pick(this.model, 'memberId', 'couponId', 'orderSn', 'memberUsername', 'totalAmount', 'payAmount', 'effectiveAmount', 'freightAmount', 'promotionAmount', 'integrationAmount', 'couponAmount', 'discountAmount', 'redbagAmount', 'payType', 'sourceType', 'sourceSystem', 'sourceScreen', 'sourceOs', 'sourceIp', 'status', 'productStatus', 'payStatus', 'returnStatus', 'orderType', 'deliveryCompany', 'deliverySn', 'autoConfirmDay', 'integration', 'growth', 'promotionInfo', 'billType', 'billHeader', 'billContent', 'billReceiverPhone', 'billReceiverEmail', 'receiverName', 'receiverPhone', 'receiverPostCode', 'receiverProvince', 'receiverCity', 'receiverRegion', 'receiverDetailAddress', 'note', 'confirmStatus', 'deleteStatus', 'useIntegration', 'paymentTime', 'deliveryTime', 'receiveTime', 'commentTime', 'modifyTime', 'netSourceType', 'netSourceArg1', 'netSourceArg2', 'netSourceArg3', 'netSourceArg4', 'netSourceArgdetail', ))
          // 时间格式化
          this.form.setFieldsValue({ paymentTime: this.model.paymentTime ? moment(this.model.paymentTime) : null })
          this.form.setFieldsValue({ deliveryTime: this.model.deliveryTime ? moment(this.model.deliveryTime) : null })
          this.form.setFieldsValue({ receiveTime: this.model.receiveTime ? moment(this.model.receiveTime) : null })
          this.form.setFieldsValue({ commentTime: this.model.commentTime ? moment(this.model.commentTime) : null })
          this.form.setFieldsValue({ modifyTime: this.model.modifyTime ? moment(this.model.modifyTime) : null })
        })
        // 加载子表数据
        if (this.model.id) {
          let params = { id: this.model.id }
          this.requestSubTableData(this.url.omsOrderItem.list, params, this.omsOrderItemTable)
          this.requestSubTableData(this.url.omsOrderInvoice.list, params, this.omsOrderInvoiceTable)
        }
      },
 
      /** 整理成formData */
      classifyIntoFormData(allValues) {
        let main = Object.assign(this.model, allValues.formValue)
        //时间格式化
        main.paymentTime = main.paymentTime ? main.paymentTime.format('YYYY-MM-DD HH:mm:ss') : null;
        main.deliveryTime = main.deliveryTime ? main.deliveryTime.format('YYYY-MM-DD HH:mm:ss') : null;
        main.receiveTime = main.receiveTime ? main.receiveTime.format('YYYY-MM-DD HH:mm:ss') : null;
        main.commentTime = main.commentTime ? main.commentTime.format('YYYY-MM-DD HH:mm:ss') : null;
        main.modifyTime = main.modifyTime ? main.modifyTime.format('YYYY-MM-DD HH:mm:ss') : null;
        return {
          ...main, // 展开
          omsOrderItemList: allValues.tablesValue[0].values,
          omsOrderInvoiceList: allValues.tablesValue[1].values,
        }
      }
    }
  }
</script>

<style scoped>
</style>